package indi.zn.commons.reflection;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

public abstract class ParameterizedClass<T> {

	protected Class<T> clazz;
	
	
	
	public static Type[] getParameterizedTypes(Object obj) {
	
		ParameterizedType parameterizedType = (ParameterizedType) obj.getClass().getGenericSuperclass();  
    
		Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
		return actualTypeArguments;  
		
	}
	
	
	@SuppressWarnings("unchecked")
	protected  ParameterizedClass() {
		
		 clazz = (Class<T>) ((ParameterizedType) getClass()
	                .getGenericSuperclass()).getActualTypeArguments()[0]; 
	
	}
	
	
	
	static class Test extends ParameterizedClass<String> {
		
		
		public static void main(String[] args) {
			
			Test tt=new Test();
			
			 System.out.println( tt.clazz);
			
		}
		
	}
	
}
